Index: netcat-openbsd-1.89/netcat.c
===================================================================
--- netcat-openbsd-1.89.orig/netcat.c	2008-01-22 16:17:30.000000000 -0500
+++ netcat-openbsd-1.89/netcat.c	2008-01-22 16:17:34.000000000 -0500
@@ -69,6 +69,8 @@
 #define CONNECTION_FAILED 1
 #define CONNECTION_TIMEOUT 2
 
+#define UDP_SCAN_TIMEOUT 3			/* Seconds */
+
 /* Command Line Options */
 int	dflag;					/* detached, no stdin */
 int	iflag;					/* Interval Flag */
@@ -376,7 +378,7 @@
 				continue;
 
 			ret = 0;
-			if (vflag) {
+			if (vflag && !uflag) {
 				/* For UDP, make sure we are connected. */
 				if (uflag) {
 					if (udptest(s) == -1) {
@@ -841,15 +843,20 @@
 int
 udptest(int s)
 {
-	int i, ret;
+	int i, t;
 
-	for (i = 0; i <= 3; i++) {
-		if (write(s, "X", 1) == 1)
-			ret = 1;
-		else
-			ret = -1;
+	if ((write(s, "X", 1) != 1) ||
+	    ((write(s, "X", 1) != 1) && (errno == ECONNREFUSED)))
+		return -1;
+
+	/* Give the remote host some time to reply. */
+	for (i = 0, t = (timeout == -1) ? UDP_SCAN_TIMEOUT : (timeout / 1000);
+	     i < t; i++) {
+		sleep(1);
+		if ((write(s, "X", 1) != 1) && (errno == ECONNREFUSED))
+			return -1;
 	}
-	return (ret);
+	return 1;
 }
 
 void
